﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Mvc.Ajax;
using System.Web.Routing;
using IndignadoFramework.BackBone.Model;
using IndignadoFramework.FrontOffice.Models;

namespace IndignadoFramework.FrontOffice.Controllers
{
    public abstract class SiteController : Controller
    {
        ISiteProvider _siteProvider;

        public SiteController()
        {
            _siteProvider = new SiteProvider();
        }

        public SiteController(ISiteProvider siteProvider)
        {
            _siteProvider = siteProvider;
        }

        protected override void Initialize(RequestContext requestContext)
        {
            string[] host = requestContext.HttpContext.Request.Headers["Host"].Split(':');

            _siteProvider.Initialise(host[0]);
            
            base.Initialize(requestContext);
        }

        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {            
            base.OnActionExecuting(filterContext);
        }

        public MovementModel Site
        {
            get
            {
                return _siteProvider.GetCurrentSite();
            }
        }


    }
}
